

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pyamp.ui.qt.baseWidget &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../../../../index.html" />
    <link rel="up" title="pyamp.ui.qt" href="../qt.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../qt.html" accesskey="U">pyamp.ui.qt</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for pyamp.ui.qt.baseWidget</h1><div class="highlight"><pre>
<span class="c"># Copyright 2012 Brett Ponsler</span>
<span class="c"># This file is part of pyamp.</span>
<span class="c">#</span>
<span class="c"># pyamp is free software: you can redistribute it and/or modify</span>
<span class="c"># it under the terms of the GNU General Public License as published by</span>
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
<span class="c"># (at your option) any later version.</span>
<span class="c">#</span>
<span class="c"># pyamp is distributed in the hope that it will be useful,</span>
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="c"># GNU General Public License for more details.</span>
<span class="c">#</span>
<span class="c"># You should have received a copy of the GNU General Public License</span>
<span class="c"># along with pyamp.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="sd">&#39;&#39;&#39;The baseWidget module contains the BaseWidget class which provides an</span>
<span class="sd">implementation of the BaseView specific to creating an extending a</span>
<span class="sd">QWidget object.</span>

<span class="sd">&#39;&#39;&#39;</span>
<span class="kn">from</span> <span class="nn">PyQt4</span> <span class="kn">import</span> <span class="n">QtGui</span>

<span class="kn">from</span> <span class="nn">pyamp.ui.qt</span> <span class="kn">import</span> <span class="n">BaseView</span>
<span class="kn">from</span> <span class="nn">pyamp.logging</span> <span class="kn">import</span> <span class="n">Colors</span>


<div class="viewcode-block" id="LayoutType"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.LayoutType">[docs]</a><span class="k">class</span> <span class="nc">LayoutType</span><span class="p">:</span>
    <span class="sd">&#39;&#39;&#39;The LayoutType class contains definitions of the different</span>
<span class="sd">    types of layouts.</span>

<span class="sd">    &#39;&#39;&#39;</span>
    <span class="n">Vertical</span> <span class="o">=</span> <span class="s">&quot;vertical&quot;</span>
    <span class="n">Horizontal</span> <span class="o">=</span> <span class="s">&quot;horizontal&quot;</span>

    <span class="nd">@classmethod</span>
<div class="viewcode-block" id="LayoutType.get"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.LayoutType.get">[docs]</a>    <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">layoutType</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Get the Qt layout object for the given layout type.</span>

<span class="sd">        * layoutType -- The type of layout</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">layoutMap</span> <span class="o">=</span> <span class="p">{</span>
            <span class="n">LayoutType</span><span class="o">.</span><span class="n">Vertical</span><span class="p">:</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QVBoxLayout</span><span class="p">,</span>
            <span class="n">LayoutType</span><span class="o">.</span><span class="n">Horizontal</span><span class="p">:</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QHBoxLayout</span>
            <span class="p">}</span>

        <span class="n">layout</span> <span class="o">=</span> <span class="n">layoutMap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">layoutType</span><span class="p">,</span> <span class="k">lambda</span><span class="p">:</span> <span class="bp">None</span><span class="p">)</span>

        <span class="c"># Create the layout</span>
        <span class="k">return</span> <span class="n">layout</span><span class="p">()</span>

</div></div>
<div class="viewcode-block" id="BaseWidget"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget">[docs]</a><span class="k">class</span> <span class="nc">BaseWidget</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QWidget</span><span class="p">,</span> <span class="n">BaseView</span><span class="p">):</span>
    <span class="sd">&#39;&#39;&#39;The BaseWidget class provides an implementation of the</span>
<span class="sd">    :class:`amp.ui.qt.BaseView` class designed to set up and create a</span>
<span class="sd">    :class:`PyQt4.QtGui.QWidget` object.</span>

<span class="sd">    This class provides serveral functions which can be overridden by</span>
<span class="sd">    subclasses to easily add features to the BaseWidget. These functions</span>
<span class="sd">    are called in the following order during the set up process:</span>

<span class="sd">      1. configure()</span>
<span class="sd">      2. configureLayout()</span>
<span class="sd">      3. createElements()</span>
<span class="sd">      4. setupConnections()</span>

<span class="sd">    &#39;&#39;&#39;</span>
    <span class="n">__spacing</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">__leftMargin</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">__topMargin</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">__rightMargin</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">__bottomMargin</span> <span class="o">=</span> <span class="mi">0</span>

    <span class="n">layoutType</span> <span class="o">=</span> <span class="n">LayoutType</span><span class="o">.</span><span class="n">Vertical</span>
    <span class="sd">&#39;&#39;&#39;The layoutType property contains the type of layout to use for this</span>
<span class="sd">    Widget. It should be a value from the :class:`LayoutType` class.</span>

<span class="sd">    &#39;&#39;&#39;</span>

    <span class="n">tabOrder</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="sd">&#39;&#39;&#39;The tabOrder property allows concrete widgets to set their tab order.</span>
<span class="sd">    Each element in the list will be tab connected to the next element in</span>
<span class="sd">    the list. The list will cycle around to the front so the final element</span>
<span class="sd">    is tab connected to the first element.</span>

<span class="sd">    &#39;&#39;&#39;</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">controller</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">mainWindow</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
                 <span class="n">logData</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">logColor</span><span class="o">=</span><span class="n">Colors</span><span class="o">.</span><span class="n">Foreground</span><span class="o">.</span><span class="n">White</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;</span>
<span class="sd">        * name -- The name of the BaseWidget</span>
<span class="sd">        * controller -- The controller for the BaseWidget</span>
<span class="sd">        * mainWindow -- The main window</span>
<span class="sd">        * logData -- The :class:`pyamp.logging.LogData` object</span>
<span class="sd">        * logColor -- The color to use for logging</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># No widgets, or items to begin with</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__items</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">QtGui</span><span class="o">.</span><span class="n">QWidget</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="n">BaseView</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">controller</span><span class="p">,</span> <span class="n">mainWindow</span><span class="p">,</span>
                          <span class="n">logData</span><span class="p">,</span> <span class="n">logColor</span><span class="p">)</span>

        <span class="c"># Set the name of the widget to be the given name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">setObjectName</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>

    <span class="c">##### Functions for setting up and tearing down the view #####</span>

<div class="viewcode-block" id="BaseWidget.setStyleSheet"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.setStyleSheet">[docs]</a>    <span class="k">def</span> <span class="nf">setStyleSheet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">styleSheet</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set the style sheet for this widget.</span>

<span class="sd">        * styleSheet -- The StyleSheet</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">QtGui</span><span class="o">.</span><span class="n">QWidget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">styleSheet</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="BaseWidget.getWidgets"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.getWidgets">[docs]</a>    <span class="k">def</span> <span class="nf">getWidgets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Return the list of child widgets for this BaseWidget.&#39;&#39;&#39;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span>
</div>
<div class="viewcode-block" id="BaseWidget.getItems"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.getItems">[docs]</a>    <span class="k">def</span> <span class="nf">getItems</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Return the list of child items for this BaseWidget.&#39;&#39;&#39;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__items</span>
</div>
<div class="viewcode-block" id="BaseWidget.setupView"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.setupView">[docs]</a>    <span class="k">def</span> <span class="nf">setupView</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create and set up this view.&#39;&#39;&#39;</span>
        <span class="c"># Create all the sub widgets for this view</span>
        <span class="n">elements</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">createElements</span><span class="p">()</span>

        <span class="c"># Add all of the widgets, in the specified order, to the layout</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">addElements</span><span class="p">(</span><span class="n">elements</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">tabOrder</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tabOrder</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="c"># Create a list of elements with the first element at</span>
            <span class="c"># the end of the list</span>
            <span class="n">shiftedElements</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tabOrder</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">tabOrder</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

            <span class="c"># Tab connect all the elements to their shifted pair</span>
            <span class="k">for</span> <span class="n">first</span><span class="p">,</span> <span class="n">second</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tabOrder</span><span class="p">,</span> <span class="n">shiftedElements</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">setTabOrder</span><span class="p">(</span><span class="n">first</span><span class="p">,</span> <span class="n">second</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="BaseWidget.clear"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.clear">[docs]</a>    <span class="k">def</span> <span class="nf">clear</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Remove all of the child widgets and items currently for this</span>
<span class="sd">        BaseWidget.</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">clearWidgets</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">clearItems</span><span class="p">()</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__items</span> <span class="o">=</span> <span class="p">[]</span>
</div>
<div class="viewcode-block" id="BaseWidget.clearWidgets"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.clearWidgets">[docs]</a>    <span class="k">def</span> <span class="nf">clearWidgets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Clear all the widgets from this BaseWidget.&#39;&#39;&#39;</span>
        <span class="k">for</span> <span class="n">widget</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">removeWidget</span><span class="p">(</span><span class="n">widget</span><span class="p">)</span>
            <span class="n">widget</span><span class="o">.</span><span class="n">hide</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="BaseWidget.clearItems"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.clearItems">[docs]</a>    <span class="k">def</span> <span class="nf">clearItems</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Clear all the items from this BaseWidget.&#39;&#39;&#39;</span>
        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">__items</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">removeItem</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>

    <span class="c">##### Functions for manipulating the view #####</span>
</div>
<div class="viewcode-block" id="BaseWidget.addElements"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.addElements">[docs]</a>    <span class="k">def</span> <span class="nf">addElements</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">elements</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Add a list of elements to the main layout.</span>

<span class="sd">        * elements -- The list of elements</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="k">for</span> <span class="n">element</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">addElement</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="BaseWidget.addElement"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.addElement">[docs]</a>    <span class="k">def</span> <span class="nf">addElement</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">element</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Add an element to the main layout.</span>

<span class="sd">        * element -- The element to add</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="c"># Add the element depending on what type of element it is</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QLayoutItem</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">addItem</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">element</span><span class="p">,</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QWidget</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">element</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&quot;Unknown element type: [</span><span class="si">%s</span><span class="s">]&quot;</span> <span class="o">%</span> <span class="nb">type</span><span class="p">(</span><span class="n">element</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="BaseWidget.addWidget"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.addWidget">[docs]</a>    <span class="k">def</span> <span class="nf">addWidget</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">widget</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Add a widget to the main layout.</span>

<span class="sd">        * widget -- The widget to add</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">addWidget</span><span class="p">(</span><span class="n">widget</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__widgets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">widget</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="BaseWidget.addItem"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.addItem">[docs]</a>    <span class="k">def</span> <span class="nf">addItem</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Add an item to the main layout.</span>

<span class="sd">        * item -- The item to add</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">addItem</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="BaseWidget.createLayout"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.createLayout">[docs]</a>    <span class="k">def</span> <span class="nf">createLayout</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create the main layout.&#39;&#39;&#39;</span>
        <span class="c"># Create the main layout for the widget</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span> <span class="o">=</span> <span class="n">LayoutType</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">layoutType</span><span class="p">)</span>

        <span class="c"># Get rid of the spacing between components placed in the layout</span>
        <span class="c"># as well as the margins</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">setSpacing</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__spacing</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="o">.</span><span class="n">setContentsMargins</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__leftMargin</span><span class="p">,</span>
                                           <span class="bp">self</span><span class="o">.</span><span class="n">__topMargin</span><span class="p">,</span>
                                           <span class="bp">self</span><span class="o">.</span><span class="n">__rightMargin</span><span class="p">,</span>
                                           <span class="bp">self</span><span class="o">.</span><span class="n">__bottomMargin</span><span class="p">)</span>

        <span class="c"># Set the layout for this widget</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">setLayout</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mainLayout</span><span class="p">)</span>

    <span class="c">##### Functions to be overridden by the subclass #####</span>
</div>
<div class="viewcode-block" id="BaseWidget.configure"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.configure">[docs]</a>    <span class="k">def</span> <span class="nf">configure</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Configure the view.&#39;&#39;&#39;</span>
        <span class="k">pass</span>
</div>
<div class="viewcode-block" id="BaseWidget.configureLayout"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.configureLayout">[docs]</a>    <span class="k">def</span> <span class="nf">configureLayout</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Configure the layout for this view.&#39;&#39;&#39;</span>
        <span class="k">pass</span>
</div>
<div class="viewcode-block" id="BaseWidget.createElements"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.createElements">[docs]</a>    <span class="k">def</span> <span class="nf">createElements</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Create the elements for this view. Return the list of widgets,</span>
<span class="sd">        or items in the order that they should be added to the layout.</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="k">return</span> <span class="p">[]</span>
</div>
<div class="viewcode-block" id="BaseWidget.setupConnections"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.setupConnections">[docs]</a>    <span class="k">def</span> <span class="nf">setupConnections</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set up any connections this view requires.&#39;&#39;&#39;</span>
        <span class="k">pass</span>

    <span class="c">#### Getter and setter functions #####</span>
</div>
<div class="viewcode-block" id="BaseWidget.setSpacing"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.setSpacing">[docs]</a>    <span class="k">def</span> <span class="nf">setSpacing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">spacing</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set the spacing between components in the layout.</span>

<span class="sd">        * spacing -- The spacing</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__spacing</span> <span class="o">=</span> <span class="n">spacing</span>
</div>
<div class="viewcode-block" id="BaseWidget.setMargins"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.setMargins">[docs]</a>    <span class="k">def</span> <span class="nf">setMargins</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">left</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">top</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">right</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">bottom</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Set the content margins for this widget&#39;s layout.</span>

<span class="sd">        * left -- The left margin</span>
<span class="sd">        * top -- The top margin</span>
<span class="sd">        * right -- The right margin</span>
<span class="sd">        * bottom -- The bottom margin</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__leftMargin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__leftMargin</span> <span class="k">if</span> <span class="n">left</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">left</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__topMargin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__topMargin</span> <span class="k">if</span> <span class="n">top</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">top</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__rightMargin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__rightMargin</span> <span class="k">if</span> <span class="n">right</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">right</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__bottomMargin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__bottomMargin</span> <span class="k">if</span> <span class="n">bottom</span> <span class="ow">is</span> <span class="bp">None</span> <span class="k">else</span> <span class="n">bottom</span>

    <span class="c">##### Override QWidget functions #####</span>
</div>
<div class="viewcode-block" id="BaseWidget.paintEvent"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_qt_baseWidget.html#pyamp.ui.qt.baseWidget.BaseWidget.paintEvent">[docs]</a>    <span class="k">def</span> <span class="nf">paintEvent</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">_event</span><span class="p">):</span>
        <span class="sd">&#39;&#39;&#39;Override the paintEvent function to allow StylSheets to work for</span>
<span class="sd">        this QWidget.</span>

<span class="sd">        Note this function was taken from the documentation of style sheets</span>
<span class="sd">             for custom QWidget classes.</span>

<span class="sd">        * _event -- The QPaintEvent</span>

<span class="sd">        &#39;&#39;&#39;</span>
        <span class="n">opt</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QStyleOption</span><span class="p">()</span>
        <span class="n">opt</span><span class="o">.</span><span class="n">init</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>

        <span class="n">painter</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QPainter</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">style</span><span class="p">()</span><span class="o">.</span><span class="n">drawPrimitive</span><span class="p">(</span><span class="n">QtGui</span><span class="o">.</span><span class="n">QStyle</span><span class="o">.</span><span class="n">PE_Widget</span><span class="p">,</span> <span class="n">opt</span><span class="p">,</span> <span class="n">painter</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span></div></div>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../qt.html" >pyamp.ui.qt</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>